Fix: 로그인 시 READ ONLY 트랜잭션에서 FOR UPDATE 쿼리 실행 문제 해결#190
Conversation
There was a problem hiding this comment.
Summary of Changes
Hello @2anizirong, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
이 PR은 로그인 시 READ ONLY 트랜잭션 내에서 FOR UPDATE 쿼리가 실행되어 발생하는 문제를 해결합니다. 이는 UserServiceImpl 클래스의 트랜잭션 설정을 조정하여 특정 쓰기 작업이 필요한 메서드에만 쓰기 가능한 트랜잭션을 적용함으로써 이루어집니다.
Highlights
- 트랜잭션 기본 설정 변경: UserServiceImpl 클래스 레벨의 @transactional 어노테이션을 readOnly = true로 변경하여 기본적으로 읽기 전용 트랜잭션을 사용하도록 설정했습니다.
- 로그인 메서드 트랜잭션 설정: loginUser 메서드에 @transactional(readOnly = false)를 명시적으로 추가하여 로그인 과정에서 필요한 쓰기 작업(예: 사용자 정보 업데이트)이 올바르게 처리되도록 했습니다.
- 사용자 정보 조회 메서드 트랜잭션 설정: getLoginUser 메서드에 @transactional(propagation = Propagation.REQUIRES_NEW, readOnly = false)를 추가하여 새로운 트랜잭션에서 쓰기 작업이 가능하도록 설정했습니다. 이는 기존 READ ONLY 트랜잭션과의 충돌을 방지합니다.
- Propagation 임포트: org.springframework.transaction.annotation.Propagation 클래스를 임포트했습니다.
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.
| Feature | Command | Description |
|---|---|---|
| Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
| Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
| Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
| Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
There was a problem hiding this comment.
Code Review
이 PR은 로그인 시 읽기 전용 트랜잭션에서 FOR UPDATE 쿼리가 실행되는 문제를 해결하기 위해 서비스 클래스에 @Transactional(readOnly = true)를 기본으로 설정하고, 쓰기 작업이 필요한 loginUser 및 getLoginUser 메서드에 @Transactional(readOnly = false)를 명시적으로 추가했습니다. 이는 좋은 접근 방식이지만, 클래스 레벨의 변경으로 인해 다른 쓰기 메서드들이 영향을 받게 되었습니다. 여러 메서드들이 데이터베이스에 쓰는 작업을 수행하지만, 별도의 트랜잭션 설정이 없어 읽기 전용 트랜잭션으로 실행되어 오류가 발생할 것입니다. 이 문제를 해결하기 위해 쓰기 작업을 수행하는 다른 메서드들에도 @Transactional(readOnly = false) 어노테이션을 추가해야 합니다.
#️⃣연관된 이슈
📝작업 내용